package com.hgyc.mom.mes.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hgyc.mom.common.vo.Result;
import com.hgyc.mom.core.mybatis.QueryWrapperUtil;
import com.hgyc.mom.mes.entity.MesWorkOrderBomItem;
import com.hgyc.mom.mes.service.MesWorkOrderBomItemService;
import com.hgyc.mom.mes.vo.WorkOrderKitCheckVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 生产工单BOM组成Controller
 *
 * @author fwj
 * @since 2025-07-10
 */
@Tag(name = "生产工单BOM组成控制器", description = "生产工单BOM组成控制器")
@RestController
@RequestMapping("/mes/work/order/item")
public class MesWorkOrderBomItemController {
    @Autowired
    private MesWorkOrderBomItemService mesWorkOrderBomItemService;


    @Operation(summary = "查询生产工单BOM组成树列表", description = "查询生产工单BOM组成树列表")
    @PostMapping("/list")
    public Result<List<MesWorkOrderBomItem>> pageList(@Parameter(description = "查询参数") @RequestBody MesWorkOrderBomItem mesWorkOrderBomItem) {
        QueryWrapper<MesWorkOrderBomItem> wrapper = QueryWrapperUtil.build(mesWorkOrderBomItem);
        List<MesWorkOrderBomItem> list = mesWorkOrderBomItemService.list(wrapper);
        return Result.success(list);
    }

    @Operation(summary = "获取生产工单BOM组成详细信息", description = "获取生产工单BOM组成详细信息")
    @GetMapping(value = "/{id}")
    public Result<?> getInfo(@Parameter(description = "生产工单BOM组成ID") @PathVariable("id") Long id) {
        return Result.success(mesWorkOrderBomItemService.getById(id));
    }

    @Operation(summary = "齐套分析", description = "齐套分析")
    @GetMapping(value = "/kitCheck/{workOrderId}")
    public Result<List<WorkOrderKitCheckVO>> kitCheck(@PathVariable("workOrderId")  Long workOrderId) {
        return Result.success(mesWorkOrderBomItemService.kitCheck(workOrderId));
    }
}